import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation

#define canvas
fig, ax = plt.subplots()
line, = ax.plot([],[])

x0 = np.array([i for i in range(10)])
y0 = np.array([0 for i in range(10)])
#rotate
def rotate(x,y,theta):
    return x*np.cos(theta) + y *(-np.sin(theta)), x * np.sin(theta) + y * np.cos(theta)

def update(theta):
    ax.set_xlim(-10, 10)
    ax.set_ylim(-10, 10)
    ax.axis('equal')
    x,y = rotate(x0, y0, theta)
    line.set_data(x,y)
    return line

animation = FuncAnimation(fig, update, frames = np.linspace(0,np.pi*2, 100), interval = 50)

animation.save("rotate.gif", writer = "imagegick", fps = 10)
plt.show()
